  //Data Package Assembly

#define startpacket 0x01
#define endpacket   0x04
#define messagetype 0x21
#define datalength  79  //4 bytes for timestamp, 26 for sensors + 49 for GPS String

unsigned char DataMessage[86]; //byte array for data storage

unsigned long* TimePoint=(unsigned long*)DataMessage[4];
unsigned short* MessagePoint=(unsigned short*)DataMessage[2];
unsigned char* GPSPoint=(unsigned char*)DataMessage[33];

//JUST FOR PRACTICING (DUMMY VARS)
unsigned long timestamp;
unsigned short ELycra1;
unsigned short ELycra2;
unsigned short Flex1;
unsigned short Flex2;
unsigned short Force1;
unsigned short Force2;
unsigned short MMG1;
unsigned short MMG2;
unsigned short AccX;
unsigned short AccY;
unsigned short AccZ;
unsigned short Pulse;
unsigned short Therm;
unsigned short GPS[49];

void setup()
{
  DataMessage[0]=startpacket;
  DataMessage[1]=messagetype;
  
  MessagePoint[0]=datalength;
  
  DataMessage[85]=endpacket;
}

void loop()
{
  unsigned short checksum=0;
  
  TimePoint[0]=timestamp;
  MessagePoint[3]=ELycra1; //starts 4bytes after (so two messagepoints) after messagetype because of timestamp at beginning
  MessagePoint[4]=ELycra2;
  MessagePoint[5]=Flex1;
  MessagePoint[6]=Flex2;
  MessagePoint[7]=Force1;
  MessagePoint[8]=Force2;
  MessagePoint[9]=MMG1;
  MessagePoint[10]=MMG2;
  MessagePoint[11]=AccX;
  MessagePoint[12]=AccY;
  MessagePoint[13]=AccZ;
  MessagePoint[14]=Pulse;
  MessagePoint[15]=Therm;  
  
  for(char i=0;i<49;i++) // gathering data for gps can be inputted straight from loop that has been defined, will need correct assigning of pointers
  {
    GPSPoint[i]=GPS[i]; //this can probably be shortened so GPS data is inputted into here immediately
  }
  
  for(char i=0;i<79;i++)
  {
    checksum=checksum^MessagePoint[i]; //I BELIEVE AN ADDITIONAL BYTE NEEDS TO BE APPENDED SO THAT CHECKSUM IS CALCULATED CORERECTLY!!!
  }
}
